import requestProxy from '@/utils/request';

const { request } = requestProxy;

// 项目列表-tab
export function getProjectTab(params) {
  return request({
    url: '/admin/project/list/tab',
    method: 'get',
    params
  });
}

// 项目列表
export function getList(params) {
  return request({
    url: '/admin/project/list',
    method: 'get',
    params
  });
}

// 项目删除
export function projectDel(id) {
  return request({
    url: `admin/project/del/${id}`,
    method: 'delete'
  });
}

// 项目列表-项目详情
export function projectListInfo(id) {
  return request({
    url: `admin/project/list/info/${id}`,
    method: 'get'
  });
}

/**
 * 项目详情
 */

// 项目详情-收入项
export function getIncomeList(id, params) {
  return request({
    url: `/admin/project/incomeList/${id}`,
    method: 'get',
    params
  });
}

// 项目详情-订单明细
export function getOrderList(id, page, perPage, params) {
  return request({
    url: `/admin/project/orderList/${id}`,
    method: 'get',
    params: {
      page,
      perPage,
      ...params
    }
  });
}

// 项目详情-项目类型选择
export function getProjectTypes(params) {
  return request({
    url: '/admin/project/types',
    method: 'get',
    params
  });
}

// 项目详情-收入项删除
export function deleteIncomeItem(id) {
  return request({
    url: `/admin/project/income/${id}`,
    method: 'delete'
  });
}

// 新增项目
export function projectAdd(data) {
  return request({
    url: 'admin/project/create',
    method: 'post',
    data
  });
}

// 项目详情-添加收入项
export function addIncomeItem(id, data) {
  return request({
    url: `/admin/project/addIncome/${id}`,
    method: 'post',
    data
  });
}

// 编辑项目
export function projectEdit(id, data) {
  return request({
    url: `admin/project/edit/${id}`,
    method: 'put',
    data
  });
}

// 项目详情-编辑收入项
export function editIncomeItem(id, data) {
  return request({
    url: `/admin/project/editIncome/${id}`,
    method: 'put',
    data
  });
}

// 项目列表的高级筛选所属部门下拉框
export function getDepartment(params) {
  return request({
    url: 'admin/department/list',
    method: 'get',
    params
  });
}

// 项目详情-订单列表-编辑收入项-获取该收入项信息
export function getIncomeItemInfo(id) {
  return request({
    url: `/admin/project/incomeInfo/${id}`,
    method: 'get'
  });
}

// 订单操作记录
export function getOperateReports(params) {
  return request({
    url: 'admin/project/log',
    method: 'get',
    params
  });
}

// 修改操作记录备注
export function editLogRemark(data) {
  return request({
    url: 'admin/project/log/remarks',
    method: 'post',
    data
  });
}

// 项目详情-成本列表
export function getCostList(id, params) {
  params.notShowNoAuthTip = true;
  return request({
    url: `/admin/project/costList/${id}`,
    method: 'get',
    params
  });
}

// 项目详情-成本列表-成本项
export function costList() {
  return request({
    url: 'admin/project/select/costList',
    method: 'get'
  });
}

// 订单明细信息
export function getProjectOrder(id) {
  return request({
    url: `admin/project/order/${id}`,
    method: 'get'
  });
}

// 项目详情-成本列表
export function getCostNum(id) {
  return request({
    url: `/admin/project/costItemNum/${id}`,
    method: 'get'
  });
}

// 项目详情-删除成本
export function costDel(id) {
  return request({
    url: `/admin/project/cost/del/${id}`,
    method: 'delete'
  });
}

// 项目详情-新增成本
export function costAdd(id, data) {
  return request({
    url: `/admin/project/addCost/${id}`,
    method: 'post',
    data
  });
}

// 项目详情-编辑成本
export function costEdit(id, data) {
  return request({
    url: `/admin/project/editCost/${id}`,
    method: 'put',
    data
  });
}

// 项目详情-成本列表-按照供应商展示-可抵扣税率修改
export function discountEdit(id, data) {
  return request({
    url: `admin/project/costList/discount/edit/${id}`,
    method: 'put',
    data
  });
}

// 订单明细编辑订单
export function editProjectOrder(id, data) {
  return request({
    url: `admin/project/order/${id}`,
    method: 'put',
    data
  });
}

// 订单明细新增订单
export function addProjectOrder(id, data) {
  return request({
    url: `admin/project/order/${id}`,
    method: 'post',
    data
  });
}

// 订单明细删除
export function deleteProjectOrder(id) {
  return request({
    url: `admin/project/order/${id}`,
    method: 'delete'
  });
}

// 项目详情-核销记录
export function getChargeReportList(id, page, perPage, params) {
  return request({
    url: `admin/project/chargeReportList/${id}`,
    method: 'get',
    params: {
      page,
      perPage,
      ...params
    }
  });
}

// 项目详情-核销记录-撤销核销
export function getRepealWriteOff(id, type = 1) {
  return request({
    url: `admin/writeOff/${id}/cancel?type=${type}`,
    method: 'put'
  });
}

// 子订单列表
export function getProjectChildOrder(params) {
  return request({
    url: 'admin/project/child/order/list',
    method: 'get',
    params
  });
}

// 子订单新建
export function projectChildAdd(data) {
  return request({
    url: 'admin/project/child/add',
    method: 'post',
    data
  });
}

// 子订单编辑
export function projectChildEdit(id, data) {
  return request({
    url: `admin/project/child/edit/${id}`,
    method: 'put',
    data
  });
}

// 子订单删除
// export function projectChildDel(id) {
//   return request({
//     url: `admin/project/child/del/${id}`,
//     method: 'delete'
//   });
// }

// 子订单详情
// export function projectChildInfo(id) {
//   return request({
//     url: `admin/project/child/info//${id}`,
//     method: 'get'
//   });
// }

// 项目名称列表
export function projectNameList(params) {
  return request({
    url: 'admin/project/name/list',
    method: 'get',
    params
  });
}

// 项目子订单列表-统计
export function projectOrderTotal(params) {
  return request({
    url: 'admin/project/child/order/statistics',
    method: 'get',
    params
  });
}

export function batchAddIncome(data) {
  return request({
    url: 'admin/project/batch/addIncome',
    method: 'post',
    data
  });
}
export function batchEditIncome(data) {
  return request({
    url: 'admin/project/batch/editIncome',
    method: 'put',
    data
  });
}
export function batchDeleteIncome(data) {
  return request({
    url: 'admin/project/delete/batch/income',
    method: 'delete',
    data
  });
}
export function batchGetIncomeList(params) {
  return request({
    url: 'admin/project/batch/incomeInfo',
    method: 'get',
    params
  });
}

export function batchAddCost(data) {
  return request({
    url: 'admin/project/batch/addCost',
    method: 'post',
    data
  });
}
export function batchEditCost(data) {
  return request({
    url: 'admin/project/batch/editCost',
    method: 'put',
    data
  });
}
export function batchDeleteCost(data) {
  return request({
    url: 'admin/project/delete/batch/cost',
    method: 'delete',
    data
  });
}
// 数据看板
export function getOrderStatistics(params) {
  return request({
    url: 'admin/project/list/statistics',
    method: 'get',
    params
  });
}

// 开启批量采集
export function batchPick(data) {
  return request({
    url: 'admin/project/child/list/batchPick',
    method: 'post',
    data
  });
}
